package com.ssyc.gsk_master.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.TextView;

import com.ssyc.common.adapter.ViewHolder;
import com.ssyc.gsk_master.R;
import com.ssyc.gsk_master.bean.RedPackageInfo;

import java.util.List;

//红包定制方案
public class DiyRedpackageAdapter extends BaseAdapter {
	
	protected Context mContext;
	
	protected List<RedPackageInfo> mDatas;
	
	protected LayoutInflater mInflater;
	
	private int layoutId;
	
	private EditText et_money;
	
	private EditText et_number;

	private TextView tv_bg_zimu;
	
	private String[] items;

	public DiyRedpackageAdapter(Context context, List<RedPackageInfo> datas,
                                int layoutId) {
		this.mContext = context;
		mInflater = LayoutInflater.from(context);
		this.mDatas = datas;
		this.layoutId = layoutId;
		items = context.getResources().getStringArray(R.array.zimu_item);
	}

	@Override
	public int getCount() {
		return mDatas.size();
	}

	@Override
	public RedPackageInfo getItem(int position) {
		return mDatas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = ViewHolder.get(mContext, convertView, parent,
				layoutId, position);
		// convert(holder, getItem(position));

		et_money = holder.getView(R.id.et_money);
		et_number = holder.getView(R.id.et_number);
		tv_bg_zimu = holder.getView(R.id.tv_bg_zimu);

		et_money.setText(mDatas.get(position).money + "");

		et_number.setText(mDatas.get(position).number + "");

		tv_bg_zimu.setText(items[position]);

		et_money.setFocusable(false);
		et_number.setFocusable(false);

		return holder.getConvertView();
	}

	public void updateListView(List<RedPackageInfo> datas) {
		this.mDatas = datas;
		notifyDataSetChanged();
	}
}
